﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebService.Connect;
using System.Data.SqlClient;
using Model;
using System.Data;


namespace WebService.Datalayer
{
    public class DBRegions
    {
        Database db = new Database();
        SqlParameter[] listParameter;

        /// <summary>
        /// SelectRegions
        /// </summary>
        /// <returns></returns>
        public DataSet SelectRegionsAll()
        {
            return db.GetDataset("sp_SelectRegionsAll");
        }

        /// <summary>
        /// SelectRegionsByAndRegionID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public DataSet SelectRegionsByAndRegionID(Regions obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@RegionID", obj.RegionID),
            };
            return db.GetDataSetWithParameter("sp_SelectRegionsByAndRegionID", listParameter);
        }

        /// <summary>
        /// DeleteRegion
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int DeleteRegion(Regions obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@RegionID", obj.RegionID),
            };
            return db.ExcuteQueryWithParamater("sp_DeleteRegion", listParameter);
        }

        /// <summary>
        /// InsertRegion
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int InsertRegion(Regions obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@RegionName", obj.RegionName),
                new SqlParameter("@Description", obj.Description),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
            };
            return db.ExcuteQueryWithParamater("sp_InsertRegion", listParameter);
        }
        
        /// <summary>
        /// UpdateRegion
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int UpdateRegion(Regions obj)
        {
            listParameter = new SqlParameter[]
            {
                new SqlParameter("@RegionID", obj.RegionID),
                new SqlParameter("@RegionName", obj.RegionName),
                new SqlParameter("@Description", obj.Description),
                new SqlParameter("@IsDeleted", obj.IsDeleted),
            };
            return db.ExcuteQueryWithParamater("sp_UpdateRegion", listParameter);
        }
    }
}
